package ia1011.zanzibar.rules;

import ia1011.zanzibar.featurestructures.FeatureStructure;

/**
 * * This class represents an aggregation rule.
 *  
 * @author Alessandro Perrino (creator) 
 * @author <br> Bastianelli E. emanuele.bastianelli@gmail.com (modifier) 
 * @author <br> Caponi E. emiliano.caponi@gmail.com (modifier)
 * @author <br> Castellucci G. castellucci.giuseppe@gmail.com (modifier) 
 * @author <br> Rossi A. berardino.viola@gmail.com (modifier) 
 *  
 */
public class Rule implements Cloneable {
	
	
	// Feature structure which represents the right-hand-side of the rule
	FeatureStructure rhs;
	// FSRegEx which represents the left-hand-side of the rule
	FSRegEx lhs;
	// the weight of the rule
	int weight; 
	
	/**
	 * Initializes the rule with the specified left-hand-side,  
	 * right-hand-side and weight.
	 * @param lhs left-hand-side left-hand-side of the rule
	 * @param rhs right-hand-side of the rule
	 * @param weight weight of the rule
	 */
	public Rule(FSRegEx lhs, FeatureStructure rhs, int weight) {
		// buildSyntheticRepr(l,r);
		this.rhs=rhs;
		this.lhs=lhs;
		this.weight = weight;
	}
	
	/**
	 * 
	 * @return the regular expression structure which represents the left-hand-side of 
	 * the rule.
	 */
	public FSRegEx getLhs() {
		return this.lhs;
	}
	
	/**
	 * 
	 * @return the feature structure which represents the right-hand-side of the rule.
	 */
	public FeatureStructure getRhs() {
		return this.rhs;
	}
	
	/**
	 * 
	 * @return the weight of the rule
	 */
	public int getWeight() {
		return this.weight;
	}
	
	/**
	 * Prints a simple representation of a Rule. 
	 */
	public void display() {
		rhs.display();
		System.out.println("--->");
		lhs.display();
	}
}
